<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>计数器</title>
	</head>
	<body>
		<input type="button"  value="开始计数" onclick="start()"/>
		<input type="text"/ id="count">
		<input type="button"  value="停止计数" onclick="stop()"/>
		<script>
			var num=1;
			var i;
			function start(){
				document.getElementById('count').value=num;
				num=num+1;
				i=setTimeout("start()",1000);
			}
			function stop(){
				clearTimeout(i);
			}
		</script>
	</body>
</html>
